package hot100.logos1To10;

import java.util.HashMap;

/**
 * @author logos
 * date 2025/7/9 11:24
 * @version v1.0
 * @Package hot100
 */
public class logos1 {

    /**
     * 1.两数之和
     * https://leetcode.cn/problems/two-sum/?envType=study-plan-v2&envId=top-100-liked
     */
    class Solution {
        public int[] twoSum(int[] nums, int target) {
            HashMap<Integer, Integer> map = new HashMap<>();
            for (int i = 0; i < nums.length; i++) {
                if (map.containsKey(target - nums[i])) {
                    return new int[] { map.get(target - nums[i]), i };
                }
                map.put(nums[i], i);
            }
            return new int[] { -1, -1 };
        }
    }
}
